﻿using UnityEditor;
using UnityEngine;

namespace ZyGame.Editor.Process
{
    internal class CopySeletionGameObjectPathProcess
    {
        public static string Running()
        {
            if (Selection.activeGameObject == null)
            {
                return string.Empty;
            }

            string path = Selection.activeGameObject.name;
            Transform parent = Selection.activeGameObject.transform.parent;
            while (parent != null)
            {
                if (parent != null)
                {
                    path = parent.name + "/" + path;
                }

                parent = parent.parent;
            }
            TextEditor text = new TextEditor();
            text.text = path;
            text.SelectAll();
            text.Copy();
            return path;
        }
    }
}
